package club.dortware.client.module.impl.exploit;

import club.dortware.client.event.impl.PacketEvent;
import club.dortware.client.module.Module;
import club.dortware.client.module.annotations.ModuleData;
import club.dortware.client.module.enums.ModuleCategory;
import club.dortware.client.module.impl.combat.AutoPot;
import com.google.common.eventbus.Subscribe;
import net.minecraft.network.play.client.C02PacketUseEntity;
import net.minecraft.network.play.client.C03PacketPlayer;

@ModuleData(name = "Infinite Durability", category = ModuleCategory.EXPLOIT)
public class InfiniteDurability extends Module {

    private boolean attacked;

    @Subscribe
    public void onPacket(PacketEvent event) {
        if (event.getPacket() instanceof C02PacketUseEntity) {
            AutoPot.swap(9, mc.thePlayer.inventory.currentItem);
            attacked = true;
        }

        if (event.getPacket() instanceof C03PacketPlayer) {
            if (attacked) {
                attacked = false;
                AutoPot.swap(9, mc.thePlayer.inventory.currentItem);
            }
        }
    }

}
